using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace MoEngine
{
    public class GraphCollection : ICollection<Graph2D>
    {
        #region ICollection<Graph2D> Members

        List<Graph2D> m_Graphs = new List<Graph2D>();

        public void Add(Graph2D item)
        {
            m_Graphs.Add(item);
        }

        public void Clear()
        {
            m_Graphs.Clear();
        }

        public bool Contains(Graph2D item)
        {
            return m_Graphs.Contains(item);
        }

        public void CopyTo(Graph2D[] array, int arrayIndex)
        {
            m_Graphs.CopyTo(array, arrayIndex);
        }

        public int Count
        {
            get { return m_Graphs.Count; }
        }

        public bool IsReadOnly
        {
            get { return false; }
        }

        public bool Remove(Graph2D item)
        {
            return m_Graphs.Remove(item);
        }

        #endregion

        #region IEnumerable<Graph2D> Members

        public IEnumerator<Graph2D> GetEnumerator()
        {
            return m_Graphs.GetEnumerator();
        }

        #endregion

        #region IEnumerable Members

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }

        #endregion

        public void UpdateAll(GameTime gameTime)
        {
            foreach (Graph2D graph in m_Graphs)
            {
                graph.UpdateAll(gameTime);
            }
        }

        public void RenderAll(Camera2D camera, SpriteBatch spriteBatch)
        {
            foreach (Graph2D graph in m_Graphs)
            {
                graph.RenderAll(camera, spriteBatch);
            }
        }
    }
}
